<template>
  <div class="common-page f-c">
    <BackPage title="用户疑问列表" />
    <div class="search-params f-r a-c j-b">
      <el-form inline>
        <el-form-item label="企业名称：">
          <el-input clearable v-model="searchParams.projectName" />
        </el-form-item>
        <el-form-item label="问题类型：">
          <el-select clearable v-model="searchParams.problemType">
            <el-option v-for="item in options1" :key="item.value" :value="item.value" :label="item.name" />
          </el-select>
        </el-form-item>
        <el-form-item label="服务状态：">
          <el-select clearable v-model="searchParams.status">
            <el-option v-for="item in options2" :key="item.value" :value="item.value" :label="item.name" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" round @click="onSearch">筛选</el-button>
          <el-button round @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="table-box f-g">
      <el-table
        height="100%"
        v-loading="loading"
        stripe
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column type="index" width="80px" label="序号" />
        <el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
        <el-table-column label="附件资料">
          <template slot-scope="scope">
            <ClickDownload :file="scope.row.file"/>
          </template>
        </el-table-column>
        <el-table-column label="服务状态">
          <template slot-scope="scope">
            <el-tag :type="scope.row.statusType">{{ scope.row.statusName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="服务方式" prop="solutionName" />
        <el-table-column label="操作" fixed="right" width="120px">
          <template slot-scope="scope">
            <el-button type="text" @click="onRead(scope.row)">查看</el-button>
            <el-button type="text" @click="onDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo"
        :page-sizes="pageSizes"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize"
        @size-change="changePageSize"
        @current-change="changePageNo"
      />
    </div>
    <ItemDetail ref="ItemDetailRef" @get-page="initData"/>
  </div>
</template>

<script>
import crud from '@/mixins/crud'
import ItemDetail from './detail'
import { handleStatus, serve_way } from '@/dict'
import { http_userqs } from '@/api'

export default {
  name: 'Index',
  components: {
    ItemDetail
  },
  mixins: [crud],
  data() {
    return {
      request: http_userqs,
      searchParams: {
        projectName: '',
        problemType: '',
        status: ''
      },
      options1: [
        { value: 1, name: '地块未交付' },
        { value: 2, name: '农转用' },
        { value: 3, name: '三通一平' },
        { value: 4, name: '土地出让' },
        { value: 5, name: '土地征收' },
        { value: 6, name: '土地容积率' },
        { value: 7, name: '地块不合适' },
        { value: 8, name: '方案设计' },
        { value: 9, name: '安评能评环评' },
        { value: 10, name: '施工图审' },
        { value: 11, name: '施工困难' },
        { value: 12, name: '违章建筑' },
        { value: 13, name: '规划验收' },
        { value: 14, name: '消防验收' },
        { value: 15, name: '城管验收' },
        { value: 16, name: '政策冲突' }
      ],
      options2: handleStatus,
      columns: [
        { prop: 'projectName', label: '企业名称' },
        { prop: 'problemTypeName', label: '问题类型' },
        { prop: 'describes', label: '问题描述' }
      ],
      tableData: [
      ]
    }
  },
  methods: {
    formatTableData(data) {
      data.forEach(el => {
        el.problemTypeName = this.options1.find(item => item.value == el.problemType)?.name
        el.statusName = this.options2.find(item => item.value == el.status)?.name
        el.statusType = this.options2.find(item => item.value == el.status)?.type
        el.solutionName = serve_way[el.solution]
      })
    },
    onRead(item) {
      this.$refs.ItemDetailRef.open(item)
    }
  }
}
</script>

<style scoped lang="scss">
</style>
